package com.xjoyt.pay.share.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.share.interfaces.EmailContract;
import com.xjoyt.pay.share.params.EmailPageParam;
import com.xjoyt.pay.share.params.EmailParam;
import com.xjoyt.pay.share.po.Email;
import com.xjoyt.pay.share.services.EmailService;

@RestController
@RequestMapping("email")
public class EmailController extends AbstractController implements EmailContract {

	@Autowired
	private EmailService service;

	@Override
	public ExecuteResult<String> sendEmail(@RequestBody EmailParam param) throws Exception {
		return service.send(param);
	}

	@Override
	public PageResult<Email> loadPage(@RequestBody PageParam<EmailPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public ExecuteResult<String> validateCode(@RequestBody EmailParam param) throws Exception {
		return service.validate(param);
	}

	@Override
	public ExecuteResult<?> removeCode(@RequestBody EmailParam param) throws Exception {
		return service.remove(param);
	}
}
